Component({
  properties: {
    user: {
      type: Object,
      value: {},
      observer(newVal, oldVal, changedPath) {
        if (Object.keys(newVal).length > 0) {
          this.setData({
            count: newVal.order_count
          })
        }
      }
    },
  },
  data: {
    list: [
      { image: 'non_payment', text: '待付款', url: 'non_payment', type: 2 },
      { image: 'paid', text: '待发货', url: 'paid', type: 3 },
      { image: 'wait_receiving', text: '待收货', url: 'wait_receiving', type: 4 },
      { image: 'received', text: '待评价', url: 'received', type: 5 },
      { image: 'service', text: '售后', url: 'service', type: 6 },
    ],
    count: {}
  },
  methods: {
    handleClick(event) {
      const item = event.currentTarget.dataset.item
      wx.navigateTo({
        url: '/sub_service/pages/order/index?type=' + item.type
      })
    },
    viewAll() {
      wx.navigateTo({
        url: '/sub_service/pages/order/index?type=0'
      })
    }
  }
});
